package com.xyp.sso.entity;

import java.io.Serializable;
import java.util.List;

public class SSOShiroUser implements Serializable {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = 5980797612627817629L;

    private User user;

    private List<SSOCompany> company;

    private List<Role> roles;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public List<SSOCompany> getCompany() {
        return company;
    }

    public void setCompany(List<SSOCompany> company) {
        this.company = company;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    @Override
    public String toString() {
        return "SSOShiroUser [user=" + user + ", company=" + company + ", roles=" + roles + "]";
    }

    public SSOShiroUser() {
        super();
    }

    public SSOShiroUser(User user, List<SSOCompany> company, List<Role> roles) {
        super();
        this.user = user;
        this.company = company;
        this.roles = roles;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((company == null) ? 0 : company.hashCode());
        result = prime * result + ((user == null) ? 0 : user.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof SSOShiroUser)) {
            return false;
        }
        SSOShiroUser other = (SSOShiroUser) obj;
        if (company == null) {
            if (other.company != null) {
                return false;
            }
        } else if (!company.equals(other.company)) {
            return false;
        }
        if (user == null) {
            if (other.user != null) {
                return false;
            }
        } else if (!user.equals(other.user)) {
            return false;
        }
        return true;
    }

    public static SSOShiroUser getDefaultShiroUser() {

        return new SSOShiroUser(User.getDefaultUser(), SSOCompany.getDefaultCompanyList(2), Role.getDefaultRole(2));

    }

}
